package server

import (
	"ginfwk/adapter/facade/http"
	gServer "ginfwk/framework/core/server"
	"github.com/spf13/cobra"
	"log"
)

type Server struct {
}

func (r *Server) Register(cmd *cobra.Command) {
	// register http server
	httpCmd := &cobra.Command{
		Use:   "httpserver",
		Short: "Run http server",
		Long:  `Start a new http server and handle http route actions.`,
		Run:   r.BootHttpServer,
	}
	cmd.AddCommand(httpCmd)
}

func (a *Server) BootHttpServer(cmd *cobra.Command, args []string) {
	log.Println("cmd admin.info success, args:", args)

	// 初始化 kernel
	httpKernel := new(http.AppKernel)

	// 实例化http服务类
	httpServer := gServer.NewHttpServer(httpKernel)

	// 启动Http服务
	httpServer.Run()
}
